package com.dhcc.producter.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitDirectExchangeConfiguration {

	// 交换机
	@Bean
	public Exchange directExchange() {
		Exchange exchange = ExchangeBuilder.directExchange("direct-exchange").durable(true).build();
		return exchange;
	}
	
	// 队列
	@Bean
	public Queue directQueue01() {
		Queue queue = QueueBuilder.durable("direct-queue-01").build();
		return queue;
	}
	
	@Bean
	public Queue directQueue02() {
		Queue queue = QueueBuilder.durable("direct-queue-02").build();
		return queue;
	}
	
	// 关系
	@Bean
	public Binding directExchangeQueue01() {
		Binding binding01 = BindingBuilder.bind(directQueue01()).to(directExchange()).with("student").noargs();
		return binding01;
	}
	
	@Bean
	public Binding directExchangeQueueStudent() {
		Binding binding02 = BindingBuilder.bind(directQueue02()).to(directExchange()).with("student").noargs();
		return binding02;
	}
	@Bean
	public Binding directExchangeQueueDancer() {
		Binding binding02 = BindingBuilder.bind(directQueue02()).to(directExchange()).with("dancer").noargs();
		return binding02;
	}
}
